package com.example.mbl.controller;

import com.example.mbl.dto.ResearchArticleDto;
import com.example.mbl.entity.Event;
import com.example.mbl.entity.Research;
import com.example.mbl.interceptor.AppToken;
import com.example.mbl.result.PageResult;
import com.example.mbl.result.WebRestResult;
import com.example.mbl.result.business.EventPageResult;
import com.example.mbl.result.business.EventResult;
import com.example.mbl.result.business.ResearchPageResult;
import com.example.mbl.result.business.ResearchResult;
import com.example.mbl.service.ResearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("Research")
public class ResearchController {
    @Autowired
    private ResearchService researchService;

    @AppToken
    @PostMapping("addResearch")
    public WebRestResult addEvent(@RequestBody Research research){
        WebRestResult result = researchService.addResearch(research);
        return result;
    }

    @AppToken
    @PostMapping("deleteResearch")
    public WebRestResult deleteResearch(@RequestBody Research research){
        WebRestResult result = researchService.deleteResearch(research);
        return result;
    }

    @AppToken
    @PostMapping("updateResearch")
    public WebRestResult updateResearch(@RequestBody Research research){
        WebRestResult result = researchService.updateResearch(research);
        return result;
    }

    @AppToken
    @PostMapping("setResearchVisible")
    public WebRestResult setResearchVisible(@RequestBody Research research){
        WebRestResult result = researchService.setResearchVisible(research);
        return result;
    }

    @GetMapping("getResearchList")
    public PageResult<ResearchPageResult> getResearchList(String name, int page, int pagesize){
        PageResult<ResearchPageResult> result = researchService.getResearchList(name,page,pagesize);
        return result;
    }

    @GetMapping("getResearchItem")
    public ResearchResult getResearchItem(String researchid){
        ResearchResult result = researchService.getResearchItem(researchid);
        return result;
    }

    @AppToken
    @PostMapping("addResearchArticle")
    public WebRestResult addResearchArticle(@RequestBody ResearchArticleDto researchArticleDto){
        WebRestResult result = researchService.addResearchArticle(researchArticleDto);
        return result;
    }

    @AppToken
    @PostMapping("deleteResearchArticle")
    public WebRestResult deleteResearchArticle(@RequestBody ResearchArticleDto researchArticleDto){
        WebRestResult result = researchService.deleteResearchArticle(researchArticleDto.getId());
        return result;
    }
}
